package dfsketches.gr3d;

import java.util.Collection;
import java.util.Vector;

public class Bone {
	
	public Bone() {
	}
	
	public Bone(Vector<Vertex> vs, Vector<Bone> sb) {
		vertices = new Vertex[vs.size()];
		int n = 0;
		for (Vertex v : vs) {
			vertices[n++] = v;
		}
			
		subBones = new Bone[sb.size()];
		int m = 0;
		for (Bone b : sb) {
			subBones[m++] = b;
			b.parent = this;
		}
	}

	Bone parent;
	Vertex[] vertices;
	Bone[] subBones;

	public void verticesToCollection(Collection<Vertex> vs) {
		for (Vertex v : vertices) {
			vs.add(v);
		}
		for (Bone b : subBones) {
			b.verticesToCollection(vs);
		}
	}

	public void apply(Matrix3D m) {
		for (Vertex v : vertices) {
			v.apply(m);
		}
		for (Bone b : subBones) {
			b.apply(m);
		}
	}
}
